package com.pagoda.nerp.web.common.buildTree;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Yd on  2017-12-13
 * @Description：
 **/
public class Tree<T extends TreeNode> {
    T entity;
    List<Tree> children;


    public Tree(T entity) {
        this.entity = entity;
    }

    public String getName() {
        return entity.getName();
    }

    public String getId() {
        String code=entity.getCode();
        return code.substring(code.length()-36,code.length());
    }

    public T getEntity() {
        return entity;
    }

    public void setEntity(T entity) {
        this.entity = entity;
    }

    public List<Tree> getchildren() {
        if (children == null) {
            children = new ArrayList<Tree>();
        }
        return children;
    }

    public void setchildren(List<Tree> children) {
        this.children = children;
    }

    @Override
    public String toString() {
        return "Tree{" +
                "entity=" + entity +
                ", children=" + children +
                '}';
    }
}
